package com.example.li.myapplication.base;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

/**
 * Created by ly on 2016/9/29 17:04.
 */

public abstract class BaseFragment<P extends IPresenter> extends MvpFragment<P> {
    private View rootView;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        if (rootView == null) {
            rootView = inflater.inflate(getContentView(), container, false);
            operateView(rootView);
        }
        ViewGroup parent = (ViewGroup) rootView.getParent();
        if (parent != null) {
            parent.removeView(rootView);
        }
        return rootView;
    }

    /**
     * 操作rootView* @param rootView
     */
    protected void operateView(View rootView) {
    }

    protected abstract int getContentView();
}
